<?php
class Default_Model_DbTable_User extends Zend_Db_Table_Abstract
{
	protected $_name="hae_users";
	protected $_primary="id";
	protected $_sequence=true;
	public function login($username, $password)
	{
		try{
		$select= $this->select();
		$select->where("status =?",1);
		$select->where("username=?",$username);
		$select->where("password=?",$password);
		if($this->fetchRow($select) != NULL)
			return true;
		else 
			return false;
		}catch (Zend_Exception $e)
		{
			echo $e->getMessage();
		}
	}
	public function checkexist($username)
	{
		try {
			$select =$this->select();
			$select->where("username=?",$username);
			if($this->fetchRow($select) != NULL)
			{
				return true;
			}else return false;
		}catch(Zend_Exception $e)
		{
			echo $e->getMessage();
		}
	}
	public function import($username, $email, $full_name)
	{
		try {
			$row = $this->createRow();
			$row->username=$username;
			$row->email= $email;
			$row->full_name=$full_name;
			$row->status=1;
			if($row->save()>0) return true;
			else return false;
		}catch(Zend_Exception $e)
		{
			echo $e->getMessage();
		}
	}
	public function updateInfo($username, $email, $full_name)
	{
		try {
			$select = $this->select();
			$select->where("username = ?",$username);
			$row=$this->fetchRow($select);
			$row->email=$email;
			$row->full_name=$full_name;
			if($row->save()>0) return true;
			else return false;
		}catch(Zend_Exception $e)
		{
			echo $e->getMessage();
		}
	}
}